<template>
  <div class="dashboard-container">
    <!-- <component :is="currentRole" /> -->
    <div class="itemwarp">
      <div class="left">
      <h2 class="itemheader">------  运营概况  ------</h2>
      <h3>当前有  <span class="color">&nbsp 8 &nbsp</span>  个客户正在执行中；有  <span class="color">&nbsp 8 &nbsp</span>  个合同即将到期；  <span class="color">&nbsp 8 &nbsp</span>  个合同等待回款；<span class="color">&nbsp 8 &nbsp</span>个资源发生变更</h3>
      <div class="diagram">
        <div class="diagrammin" >
          <div id="myChart1" style="height:200px;width:250px;"></div>
          <div class="textname">销售任务进度</div>
        </div>
        <div class="diagrammax" >
        <div id="myChart2" style="height:275px;width:300px;"></div>
        <div class="textname">资源饱和度</div>

        </div>
        <div class="diagrammin" >
          <div id="myChart3" style="height:200px;width:250px;"></div>
          <div class="textname">资源锁失败率</div>
        </div>
      </div>
      </div>
      <div class="right">
        <div class="card">
        <div class="cardheader">团体销售冠军榜</div>
        <div class="cardtab">
          <div class="tabitem is">年度</div>
          <div class="tabitem">当月</div>
        </div>
        <div class="cardimgwap">
          <div class="cardone">
            <img src="../../assets/img/logo.jpg" class="onimg"/>
            <div class="textcard">**部门</div>
          </div>
          <div class="cardone">
            <img src="../../assets/img/logo.jpg" class="onimg"/>
            <div class="textcard">**部门</div>
          </div>
          <div class="cardone">
            <img src="../../assets/img/logo.jpg" class="onimg"/>
            <div class="textcard">**部门</div>
          </div>
        </div>
       
        </div>
         <div class="card card2">
        <div class="cardheader">个人销售冠军榜</div>
        <div class="cardtab">
          <div class="tabitem is">年度</div>
          <div class="tabitem">当月</div>
        </div>
        <div class="cardimgwap">
          <div class="cardone">
            <img src="../../assets/img/logo.jpg" class="onimg"/>
            <div class="textcard">**部门</div>
            <div class="textcard">李**</div>
          </div>
          <div class="cardone">
            <img src="../../assets/img/logo.jpg" class="onimg"/>
            <div class="textcard">**部门</div>
            <div class="textcard">李**</div>
          </div>
          <div class="cardone">
            <img src="../../assets/img/logo.jpg" class="onimg"/>
            <div class="textcard">**部门</div>
            <div class="textcard">李**</div>
          </div>
        </div>
       
        </div>
      </div>
    </div>
     <div class="backlog">
      <h2 class="itemheader">------  运营概况  ------</h2>
      <div class="hint">共<span class="color"> &nbsp 8 &nbsp</span>件待办事件 <div class="more">查看更多</div></div>
      <div class="list">
      <el-table
      :cell-style="cellstyle"
    :data="tableData3"
        :header-cell-style="$headerstyle"
    border
    style="width: 100%">
    <el-table-column
      prop="date"
      label="申请类型"
      width="150">
    </el-table-column>
    <el-table-column
      prop="address"
      label="主题"
      class-name="nameclass"
      width="499">
    </el-table-column>
    <el-table-column
      prop="date"
      label="发起时间"
      width="150">
    </el-table-column>
    <el-table-column
      prop="name"
      label="发起人"
      width="100">
    </el-table-column>
    <el-table-column
      prop="name"
      width="100"
      label="前置审批人">
    </el-table-column>
  </el-table>
      </div>
      </div>
        <div class="backlog bto" >
      <h2 class="itemheader">------  预警/消息  ------</h2>
      <div class="hint">共<span class="color"> &nbsp 8 &nbsp</span>条未读 <div class="more">查看更多</div></div>
      <div class="list">
      <el-table
    :data="tableData3"
    border
     :cell-style="$rowstyle"
        :header-cell-style="$headerstyle"
    style="width: 100%">
    <el-table-column
      prop="date"
      label="状态"
      width="100">
    </el-table-column>
    <el-table-column
      prop="address"
      label="主题"
      class-name="nameclass"
      width="619">
    </el-table-column>
    <el-table-column
      prop="date"
      label="时间"
      width="180">
    </el-table-column>
    <el-table-column
      prop="name"
      label="查看"
      width="100">
    </el-table-column>
  
  </el-table>
      </div>
      </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
// import adminDashboard from './admin'
// import editorDashboard from './editor'
import echarts from 'echarts'

export default {
  name: 'Dashboard',
  // components: { adminDashboard, editorDashboard },
  data() {
    return {
      currentRole: 'adminDashboard',
       tableData3: [{
          date: '2016-05-03',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-04',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-08',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-06',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-07',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }]
    }
  },
  computed: {
    ...mapGetters([
      'roles'
    ])
  },
  created() {
    if (!this.roles.includes('admin')) {
      this.currentRole = 'editorDashboard'
    }
  },
  mounted() {
    this.drawLine1()
     this.drawLine2()
      this.drawLine3()
  },
  methods: {
    cellstyle({ row, column, rowIndex, columnIndex }){
 if (columnIndex === 1) {
        // 指定列号
        return 'color:#0000FF;text-decoration: underline;'
      } 
    },
     drawLine1(){
        // 基于准备好的dom，初始化echarts实例
        let myChart = echarts.init(document.getElementById('myChart1'))
        // 绘制图表
        myChart.setOption({
             tooltip: {
        formatter: '{a} <br/>{b} : {c}%'
    },
    
    toolbox: {
        feature: {
            restore: {},
            saveAsImage: {}
        }
    },
    series: [
        {
            name: '业务指标',
            type: 'gauge',
            detail: {formatter: '{value}%'},
            data: [{value: 50, name: '完成率'}]
        }
    ]
        });
    },
    drawLine3(){
        // 基于准备好的dom，初始化echarts实例
        let myChart = echarts.init(document.getElementById('myChart3'))
        // 绘制图表
        myChart.setOption({
             tooltip: {
        formatter: '{a} <br/>{b} : {c}%'
    },
    toolbox: {
        feature: {
            restore: {},
            saveAsImage: {}
        }
    },
    series: [
        {
            name: '业务指标',
            type: 'gauge',
            detail: {formatter: '{value}%'},
            data: [{value: 50, name: '完成率'}]
        }
    ]
        });
    },
    drawLine2(){
        // 基于准备好的dom，初始化echarts实例
        let myChart = echarts.init(document.getElementById('myChart2'))
        // 绘制图表
        myChart.setOption({
             tooltip: {
        formatter: '{a} <br/>{b} : {c}%'
    },
  
    toolbox: {
        feature: {
            restore: {},
            saveAsImage: {}
        }
    },
    series: [
        {
            name: '业务指标',
            type: 'gauge',
            detail: {formatter: '{value}%'},
            data: [{value: 50, name: '完成率'}]
        }
    ]
        });
    },
  },
}
</script>
<style lang="scss" scoped>
.itemwarp{
  height: 440px;
  width: 100%;
  // background: red;
}
.itemheader{
  text-align: center;
  height: 50px;
  line-height: 50px;
}
h3{
  text-align: center;
  padding: 0;
}
.itemwarp{
  display: flex;
  width: 100%;
}
.right{
  width: 250px;
  height: 100%;
  // background: blue;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-items: center;
}
.left{
  flex: 1;
  display: flex;
  flex-direction: column
}

.diagrammin{
  width: 250px;
  height: 230px;
}
.diagrammax{
  width: 300px;
  height: 300px;
}
.diagram{
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
}
.card{
  width: 200px;
    height: 150px;
    // background: brown;
    border-radius: 10px;
    box-shadow:5px 5px 5px rgba(0, 0, 0, 0.349019607843137);
}
.card2{
  height: 170px;
  margin-top: 20px;
}
.card2 .textcard{
  line-height: 25px;
}
.cardheader{
  width: 100%;
  height: 25px;
  line-height: 25px;
  text-align: center;
  background: rgba(0, 86, 156, 1);
  font-size: 16px;
  color: #fff;
  border-top-right-radius: 10px;
  border-top-left-radius: 10px;
}
.cardtab{
   width: 100%;
  height: 25px;
  display: flex;
  background: #fff;
  align-items: center;
}
.tabitem{
  // color: #fff;
  margin: 0 5px;
  font-size: 18px;
}
.is{
  color: red;
  text-decoration: underline;
}
.cardimgwap{
  width: 90%;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
}
.cardone{
  width: 30%;
  height: 100px;
  // background: red;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.onimg{
  width: 100%;
  height: 70px;

}
.textcard{
  width: 100%;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 30px;
}
.textname{
  width: 100%;
  text-align: center;
  font-size: 20px;
}
.backlog{
  margin-top: 20px;
}
.hint{
  width: 1000px;
  margin: 0 auto;
  text-align: center;
  position: relative;
  margin-bottom: 10px;
}
.list{
  margin: 0 auto;
  width: 1000px;
}
.more{
   color:#0000FF;
  text-decoration: underline;
  position: absolute;
  right: 0;
  top:0;
}
.bto{
  margin-bottom: 100px;
}
.color{
  color: red;
  text-decoration: underline;
}
</style>